//
//  BaseModel.h
//  OCStarterProject
//
//  Created by huaya on 2025/10/2.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface BaseModel : NSObject <NSCoding, NSCopying>

/// 模型ID
@property (nonatomic, copy) NSString *modelId;

/// 创建时间
@property (nonatomic, strong) NSDate *createdAt;

/// 更新时间
@property (nonatomic, strong) NSDate *updatedAt;

/// 初始化方法
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;

/// 转换为字典
- (NSDictionary *)toDictionary;

/// 转换为JSON字符串
- (NSString *)toJSONString;

/// 从JSON字符串初始化
+ (instancetype)modelFromJSONString:(NSString *)jsonString;

/// 模型数组转换为字典数组
+ (NSArray *)dictionaryArrayFromModelArray:(NSArray<BaseModel *> *)models;

/// 字典数组转换为模型数组
+ (NSArray *)modelArrayFromDictionaryArray:(NSArray<NSDictionary *> *)dictionaries;

@end

NS_ASSUME_NONNULL_END
